<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/amazeui.min.css" />
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/hy.admin.css" />
	</head>

	<body>
		{include file='../Common/hy_header.html'}
		<div class="am-g">
			<div class="am-tabs am-margin" data-am-tabs="">
				<ul class="am-tabs-nav am-nav am-nav-tabs">
					<!-- <li class="am-active"><a hidefocus="true" href="#tab1">基本详情</a>
					</li>
					<li class="" ><a hidefocus="true" href="#tab3">SEO 选项</a>
					</li> -->
				</ul>

				<div class="am-tabs-bd am-form" style="touch-action: pan-y; -webkit-user-select: none; -webkit-user-drag: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);">

					<div class="am-tab-panel am-fade am-active am-in" id="tab1">
						
						<div class="am-g am-margin-top">
							<div class="am-u-sm-2 am-text-right">
								店名
							</div>
							<div class="am-u-sm-4 am-u-end">
								<input type="text" style="width:230px;" id="name" value="{$res.name}" class="am-input-sm">
							</div>
						</div>

						<div class="am-g am-margin-top">
							<div class="am-u-sm-2 am-text-right">
								卡券名称
							</div>
							<div class="am-u-sm-4 am-u-end">
								<input type="text" style="width:230px;" id="description" value="{$res.description}" class="am-input-sm">
							</div>
						</div>
						
						<div class="am-g am-margin-top">
							<div class="am-u-sm-2 am-text-right">
								卡券id
							</div>
							<div class="am-u-sm-4 am-u-end">
								<input type="text" style="width:280px;" id="card_id" value="{$res.card_id}" class="am-input-sm">
							</div>
						</div>
						
						 <div class="am-g am-margin-top">
            					<div class="am-u-sm-2 am-text-right">
              						上传图片
           						 </div>
           				 <div class="am-u-sm-4">
              				<input type="text"  name="img" id="img" class="am-input-sm" value="{$res.img}">
             
            					</div>
           					 <div class="am-u-sm-1">
            	 					<img id="hy-thumb" style="height: 30px;" {if $res.img}src="/ws{$res.img}"{else} src="{$_C.hy_path}images/logo2.png" {/if}>
            					</div>
             				<div class="am-u-sm-4 am-u-end">
             					<button class="am-btn am-btn-primary am-btn-xs hy-js-uploadimg" >上传</button>
          						</div>
     					</div>
     																
						<div class="am-g am-margin-top">
							<div class="am-u-sm-2 am-text-right">
								领取结束时间
							</div>
							<div class="am-u-sm-4 am-u-end">
								<input value="{$res.dotime2}"  style="width:230px;" type="text" id="dotime2" name="dotime2" class="field am-form-field hy-js-search">
							</div>
						</div>
						
						<div class="am-g am-margin-top">
							<div class="am-u-sm-2 am-text-right">
								每日限领量
							</div>
							<div class="am-u-sm-4 am-u-end">
								<input value="{$res.day_max}"  style="width:230px;" type="text" id="hour_max" name="day_max" class="field am-form-field hy-js-search">
							</div>
						</div>
						
						<div class="am-g am-margin-top">
							<div class="am-u-sm-2 am-text-right">
								每小时限领量
							</div>
							<div class="am-u-sm-4 am-u-end">
								<input value="{$res.hour_max}"  style="width:230px;" type="text" id="hour_max" name="hour_max" class="field am-form-field hy-js-search">
							</div>
						</div>
						
						<div class="am-g am-margin-top">
							<div class="am-u-sm-2 am-text-right">
								每分钟限领量
							</div>
							<div class="am-u-sm-4 am-u-end">
								<input value="{$res.min_max}"  style="width:230px;" type="text" id="min_max" name="min_max" class="field am-form-field hy-js-search">
							</div>
						</div>
						<!-- 
						<div class="am-g am-margin-top">
							<div class="am-u-sm-2 am-text-right">
								已领数
							</div>
							<div class="am-u-sm-4 am-u-end">
								<input value="{$res.get_total}"  style="width:230px;" type="text" id="get_total" name="get_total" class="field am-form-field hy-js-search">
							</div>
						</div> -->
						
					<div class="am-g am-margin-top">
						<label for="user-name" class="am-u-sm-2 am-text-right">是否开启</label>
						<div class="am-u-sm-4 am-u-end">
							<input type="radio" {if $res.status}{if $res.status eq 1}checked="checked" {else}{/if}{else}checked="checked" {/if} name="status" value="1" id="status1">是
							<input type="radio" {if $res.status eq 0}checked="checked" {else}{/if} name="status" value="0" id="status0">否
						</div>
					</div>
					
					<div class="am-g am-margin-top">
						<label for="user-name" class="am-u-sm-2 am-text-right">弹幕卡券</label>
						<div class="am-u-sm-4 am-u-end">
							<input type="radio" {if $res.is_chat}{if $res.is_chat eq 1}checked="checked" {else}{/if}{else}checked="checked" {/if} name="is_chat" value="1" id="is_chat1">是
							<input type="radio" {if $res.is_chat eq 0}checked="checked" {else}{/if} name="is_chat" value="0" id="is_chat0">否
						</div>
					</div>
						
						<div class="am-g am-margin-top">
							<div class="am-u-sm-2 am-text-right">
								需要积分
							</div>
							<div class="am-u-sm-4 am-u-end">
								<input value="{$res.change_integral}"  style="width:230px;" type="text" id="change_integral" name="change_integral" class="field am-form-field hy-js-search">
							</div>
						</div>
						
											
						
						<input type="hidden" id="shd" value="{$res.id}" placeholder="" >
						<div class="am-margin" style="margin-left:25%;">
							<button type="button" onclick="submit()" class="am-btn am-btn-primary am-btn-xs">提交保存</button>
						</div>

					
				</div>
				
			</div>
		</div>
		<div class="hy-footer">

		</div>
		{include file='../Common/hy_footer.html'}
		<script type="text/javascript" src="{$_C.hy_path}js/editor/kindeditor.js"></script>
		<script type="text/javascript" src="{$_C.hy_path}js/laydate/laydate.js"></script>
		<script type="text/javascript">
			$(function(){
				  

				  laydate({
				   elem: '#dotime2',
				   istime:true,
				   format: 'YYYY-MM-DD ',
				})	
			})
			
			hy_uploadimg('/card',{},function(result){
	    	if(typeof(result[0])!='undefined')
	    	{
	        	$('#hy-thumb').attr('src',"/ws"+result[0]);
	        	$('input[name=img]').val(result[0]).focus();
	       }
	    })
	    
			function submit()
			{
				
				if($("#name").val()=='')
				{
					showMsg('店名不能为空',1);
					return;
				}
				if($("#description").val()=='')
				{
					showMsg('卡券名称不能为空',1);
					return;
				}
				if($("#card").val()=='')
				{
					showMsg('卡券id不能为空',1);
					return;
				}
				
				if($("#dotime2").val()=='')
				{
					showMsg('结束时间不能为空',1);
					return;
				}
				if($("#day_max").val()=='')
				{
					showMsg('每日限领量不能为空',1);
					return;
				}
				if($("#hour_max").val()=='')
				{
					showMsg('每小时限领量不能为空',1);
					return;
				}
				if($("#min_max").val()=='')
				{
					showMsg('每分钟限领量不能为空',1);
					return;
				}
				/* if($("#get_total").val()=='')
				{
					showMsg('已领数不能为空',1);
					return;
				} */
				if($("#change_integral").val()=='')
				{
					showMsg('所需积分不能为空',1);
					return;
				}
	
				
				$.ajax({
					type:"POST",
					url:"index.php?g=admin&m=card&a=set_index",
					data:{
						id:$("#shd").val(),
						name:$("#name").val(),
						card_id:$("#card_id").val(),
						description:$("#description").val(),						
						dotime2:$("#dotime2").val(),
						day_max:$("#day_max").val(),
						hour_max:$("#hour_max").val(),
						min_max:$("#min_max").val(),
						/* get_total:$("#get_total").val(), */
						img:$("#img").val(),
						status:$("input[name=status]:checked").val(),
						is_chat:$("input[name=is_chat]:checked").val(),
						change_integral:$("#change_integral").val()
					},
					dataType:"json",
					success:function(data){
						if(data.error == 1){
							showMsg(data.content,1);
						}
						else{
							showMsg(data.content,0);
						}
					},
					error:function(){
						
					}
				});
			}
		</script>
	</body>

</html>